package org.ucas.kgraph.dto;

import org.springframework.http.HttpStatus;
import org.ucas.kgraph.entity.UserProfile;
import org.ucas.kgraph.utils.exception.NotFoundException;

/**
 * 用户信息传输对象
 *
 * @author suemi
 */
public class ProfileDto extends ResponseDto {

  public Long id;

  public ProfileDto(){ super(HttpStatus.OK,null);}

  public static ProfileDto of(UserProfile profile){
    if(profile==null) throw NotFoundException.User_NotExists;
    ProfileDto dto = new ProfileDto();
    dto.id = profile.getId();
    return dto;
  }

  public UserProfile writeTo(UserProfile profile){
    if(profile==null) throw NotFoundException.User_NotExists;
    if(profile.getId()==null) profile.setId(id);
    return profile;
  }

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }
}
